package baseClass;

import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.CheckBox;

import java.util.ArrayList;

public class RoomTable {
    //用于TableView
    private final SimpleStringProperty roomNumber = new SimpleStringProperty();
    private SimpleStringProperty roomKind = new SimpleStringProperty();
    private SimpleStringProperty price = new SimpleStringProperty();
    private SimpleStringProperty status = new SimpleStringProperty();
    private CheckBox checkBox = new CheckBox();

    public RoomTable(Room room){
        String[] properties = room.getRoomInformation();
        roomNumber.set(properties[0]);

        switch(Integer.parseInt(properties[1])){//房间种类
            case Room.SINGLE: roomKind.set("单人间"); break;
            case Room.DOUBLE: roomKind.set("双人间"); break;
            case Room.PRESIDENT: roomKind.set("总统套房"); break;
            case Room.LUXURY: roomKind.set("豪华套房"); break;
            case Room.COUPLE: roomKind.set("情侣套房"); break;
            case Room.FAMILY: roomKind.set("亲子套房"); break;
        }

        price.set(properties[2]);

        switch(Integer.parseInt(properties[3])){//房间状态
            case 0: status.set("已入住"); break;
            case 1: status.set("空闲"); break;
        }
    }

    public static ObservableList<RoomTable> getRoomTable(ArrayList<Room> rooms){
        ObservableList<RoomTable> roomTable = FXCollections.observableArrayList();
        for (Room room : rooms) {
            roomTable.add(new RoomTable(room));
        }
        return roomTable;
    }

    public String getRoomNumber(){
        return roomNumber.get();
    }

    public String getRoomKind(){
        return roomKind.get();
    }

    public String getPrice(){
        return price.get();
    }

    public String getStatus(){
        return status.get();
    }

    public CheckBox getCheckBox(){
        return checkBox;
    }
}
